package handle

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"zk2/api/basic/config"
	__ "zk2/api/basic/proto"
	"zk2/api/request"
)

func ChatAdd(c *gin.Context) {
	var req request.ChatAddReq
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusOK, gin.H{
			"data": 400,
			"code": "参数验证失败",
			"msg":  err.Error(),
		})
		return
	}
	r, err := config.Client.ChatAdd(c, &__.ChatAddReq{
		UserId:    req.UserId,
		ReceiveId: req.ReceiveId,
		Message:   req.Message,
	})
	if err != nil {
		c.JSON(http.StatusOK, gin.H{
			"data": 400,
			"code": "消息添加失败",
			"msg":  err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"data": 400,
		"code": "消息添加成功",
		"msg":  r,
	})

}
